home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
UTIL
/
SCREEN
/
CURSES01
/
minix
/
c
/
demo
< prev
next >
Wrap
Text File
|
1992-02-21
|
5KB
|
168 lines
/**********************************************************
* This is a short demo of the Minix version *
* of curses and is released into the public *
* domain. Don Cope 900906 *
**********************************************************/
#include <curses.h>
WINDOW *win1, *win2, *win3, *win4, *win5, *win6, *txwin;
main()
{
char str[20];
int d, c;
if((d = initscr()) == 0)
{
clear();
cbreak();
noecho();
win1 = newwin(10, 80, 0, 0);
win2 = newwin(7, 39, 10, 0);
win3 = newwin(6, 39, 10, 41);
win4 = newwin(3, 20, 17, 0);
win5 = newwin(3, 20, 17, 21);
win6 = newwin(3, 20, 20, 10);
txwin = newwin(24, 80, 0, 0);
wsetcolors(win4, A_COLOR(A_BLACK, A_RED));
wsetcolors(win3, A_COLOR(A_BLUE, A_WHITE));
wsetcolors(win2, A_COLOR(A_RED, A_GREEN));
wsetcolors(win5, A_COLOR(A_GREEN, A_RED));
wsetcolors(win6, A_COLOR(A_WHITE, A_BLUE));
wsetcolors(txwin, A_COLOR(A_BLACK, A_CYAN));
wclrtobot(win1);
box(win1, 0,0);
wstandout(win1);
wmove(win1,1,10);
wprintw(win1,"Standout window %d line 1",1);
wstandend(win1);
mvwaddstr(win1, 2, 10, "Normal window 1 line 2");
wattron(win1,A_UNDERLINE);
mvwaddstr(win1,3 ,10, "Underscore window 1 line 3");
wattroff(win1,A_UNDERLINE);
mvwaddstr(win1, 4, 10, "Normal window 1 line 4");
wattron(win1,A_REVERSE);
mvwaddstr(win1, 5,10, "Reverse window 1 line 5");
wattroff(win1,A_REVERSE);
mvwaddstr(win1, 6, 10, "Normal window 1 line 6");
wattron(win1,A_BOLD);
mvwaddstr(win1, 7, 10, "Bold window 1 line 7");
wattroff(win1,A_BOLD);
mvwaddstr(win1,8,10,"Back to normal window 1 line 8");
wrefresh(win1);
wclrtobot(win2);
box(win2, 0,0);
wrefresh(win2);
wstandout(win2);
wmove(win2,1,1);
wprintw(win2,"Standout window %d line 1",2);
wstandend(win2);
mvwaddstr(win2, 2, 1, "Normal window 2 line 2");
wattron(win2,A_BLINK);
mvwaddstr(win2,3,1,"Blinking window 2 line 3");
wattroff(win2,A_BLINK);
mvwaddstr(win2, 4, 1, "Normal window 2 line 4");
mvwaddstr(win2, 5, 1, "Red on Green");
wrefresh(win2);
wclrtobot(win3);
box(win3, 0,0);
wrefresh(win3);
wstandout(win3);
wmove(win3,1,5);
wprintw(win3,"Standout window 3 line 1");
wstandend(win3);
mvwaddstr(win3, 2, 5, "Normal window 3 line 2");
mvwaddstr(win3, 3, 5, "Cursor off window 3 line 3");
mvwaddstr(win3, 4, 5, "Blue on White");
cursoff();
wrefresh(win3);
sleep(2);
mvwaddstr(win3, 3, 5, "Cursor on window 3 line 3");
curson();
wrefresh(win3);
wclrtobot(win4);
box(win4, 0,0);
wrefresh(win4);
mvwaddstr(win4, 1, 1, "Black on RED");
wrefresh(win4);
wclrtobot(win5);
box(win5, 0,0);
wrefresh(win5);
mvwaddstr(win5, 1, 1, "Green on Red");
wrefresh(win5);
wclrtobot(win6);
box(win6, 0,0);
wrefresh(win6);
mvwaddstr(win6, 1, 1, "White on Blue");
wrefresh(win6);
sleep(5);
wclear(txwin);
waddstr(txwin, " This is a test program to insure that MINIX");
waddstr(txwin, " can use this curses package and\nthat most ");
waddstr(txwin, "functions work properly.");
waddstr(txwin, " Not all functions are used in this demo.\n");
waddstr(txwin," Those of you with color monitors will notice");
waddstr(txwin, " that each window has a different\nforground ");
waddstr(txwin, "and background color, however if you have a ");
waddstr(txwin, "monocrome monitor every\nthing will be ");
waddstr(txwin, "WHITE on BLACK.\n");
mvwaddstr(txwin, 12, 0, "Enter 1 to recall window 1.\n");
waddstr(txwin, " 2 to recall window 2.\n");
waddstr(txwin, " 3 to recall window 3.\n");
waddstr(txwin, " 4 to recall window 4.\n");
waddstr(txwin, " 5 to recall window 5.\n");
waddstr(txwin, " 6 to recall window 6.\n");
waddstr(txwin, " t to recall this text window.\n");
waddstr(txwin, " q to quit.\n");
mvwaddstr(txwin, 22, 0, "These are valid KEYS to enter ");
waddstr(txwin, "123456tq");
while(1)
{
mvwaddstr(txwin, 23, 5, "ENTER: ");
wrefresh(txwin);
c = wgetch(txwin);
switch(c){
case '1':
touchwin(win1);
wrefresh(win1);
break;
case '2':
touchwin(win2);
wrefresh(win2);
break;
case '3':
touchwin(win3);
wrefresh(win3);
break;
case '4':
touchwin(win4);
wrefresh(win4);
break;
case '5':
touchwin(win5);
wrefresh(win5);
break;
case '6':
touchwin(win6);
wrefresh(win6);
break;
case 't':
touchwin(txwin);
wrefresh(txwin);
break;
case 'q':
goto end;
}
}
end:
delwin(win1); delwin(win2); delwin(win3); delwin(win4);
delwin(win5); delwin(win6); delwin(txwin);
endwin();
exit(0);
}
else
{
printf("Bad return from initscr() %d\n",d);
exit(1);
}
}